package com.controller;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebFilter("/*")
public class LoginFilter extends HttpFilter{

	@Override
	protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		String uri=request.getRequestURI();
		System.out.print(uri);
		if(uri.contains("login.jsp")||uri.contains("login.do")){
			super.doFilter(request, response, chain);
			return;
		}
		if(request.getSession().getAttribute("loginAdmin")!=null) {
			super.doFilter(request, response, chain);
		}else {
			response.sendRedirect("login.jsp");
		}
	}
}
